home *** CD-ROM | disk | FTP | other *** search
- //***************************************************************************
- //
- // Copyright (C) 1990 Texas Instruments Incorporated
- // Permission is granted to any individual or institution
- // to use, copy, modify, and distribute this software,
- // provided that this complete copyright and permission notice
- // is maintained, intact, in all copies and supporting documentation.
- //
- // Texas Instruments Incorporated provides this software "as is"
- // without express or implied warranty.
- //
- //***************************************************************************
- // ensure, assumed -- macros for verifying conditions at runtime
- //
- // History:
- // 04/91 Brian M Kennedy printAndAbort moved outline
- // 02/90 Brian M Kennedy Original
- //
- //***************************************************************************
- //
- // This file defines two macros used for catching errors.
- //
- // ensure(C, S)
- // This macro verifies that the condition C is true. If not, it will
- // print the string "Expected condition is false:" followed by the string S
- // and the filename and line number. It then abort()'s, which should dump
- // core.
- //
- // assumed(C, S)
- // This macro is used to state a condition (C) that is assumed to be
- // true by the programmer. If NDEBUG is defined when this file is
- // included, then assumed(C, S) will behave as ensure(C, S). If it is
- // not defined when this file is included, then assumed(C, S) will do
- // nothing at runtime.
- //
- //***************************************************************************
-
- #include <oath/ensure.h>
-
- #include <iostream.h>
-
- /////////////////////////////////////////////////////////////////////////////
-
- void
- printAndAbort (const char * S, const char * File, int Line)
- {cerr << "Expected condition is false:" << endl;
- if(*S != '\0')
- cerr << "\t" << S << endl;
- char Buffer[160];
- sprintf(Buffer, "\tFile: \"%s\"\n\tLine: %d", File, Line);
- cerr << Buffer << endl;
- abort(); //exit and dump core
- }
-
- /***************************************************************************/
-